package cn.java81.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @author oldliu
 * @since 1.0
 */
public class AddSubject {
    //增加新课程
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            return;
        }
        String url="jdbc:mysql://localhost:3308/myschool81?useSSL=false&serverTimezone=Asia/Shanghai";
        Connection con = null;
        try {
            con = DriverManager.getConnection(url, "root", "root1234");
            Statement st = con.createStatement();
            String sql="insert into s_subject(subjectname,classhour,gradeid)values('母牛的产后护理',10,9)";
            int line = st.executeUpdate(sql);
            System.out.println("增加了："+line+"行！");
            st.close();
            con.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
